package com.ndky.annotation.reflect.four;

import java.lang.annotation.Annotation;

/**
 * 获取注解对象和属性
 * author: 核桃
 * date: 2023/11/16
 **/
public class TestFour {

    public static void main(String[] args) throws ClassNotFoundException {

        // 获取反射对象
        Class userFour = Class.forName("com.ndky.annotation.reflect.four.UserFour");

        // 获取注解对象
        Annotation declaredAnnotation = userFour.getDeclaredAnnotation(AnnoTest.class);

        if (declaredAnnotation instanceof AnnoTest) {
            AnnoTest annoTest = (AnnoTest) declaredAnnotation;

            // 获取注解属性值
            System.out.println(annoTest.name());
        }

    }
}
